class Solution {
    public:
        vector<vector<int>> findMatrix(vector<int>& nums) {
            unordered_map<int, int> mm;
            for (int& i : nums) {
                mm[i]++;
            }
            vector<vector<int>> ans;
            int len = 0;
            bool t = false;
            while (t == false) {
                t = true;
                ans.push_back(vector<int>());
                for (auto& m : mm) {
                    const int& x = m.first;
                    int & y = m.second;
                    if(y != 0){
                        t = false;
                        ans[len].push_back(x);
                        y--;
                    }
                }
                len++;
            }
            ans.pop_back();
            return ans;
        }
    };